<?php
/**
 * Created by PhpStorm.
 * User: lijie
 * Date: 2018/10/30
 * Time: 15:30
 */
namespace app\reserve\model;

use Think\Db;
use think\Model;

class Bankcard extends Model{
    protected function initialize()
    {
        //需要调用`Model`的`initialize`方法
        parent::initialize();
        //TODO:自定义的初始化
    }
    protected $autoWriteTimestamp = true;
    protected $createTime = "ctime";
    protected $updateTime = "utime";
    protected $dateFormat;
    /*
    * Notes: 添加银行卡号
    * Create Date: 2018/10/31 
    * Create Time: 下午2:08
    * Create by :张福来
    * param :
    */  
    public function addBankcard($postData){
        $result = $this
                ->save($postData);
        return  $this->id;
    }
    /*
    * Notes: 银行卡列表
    * Create Date: 2018/10/31
    * Create Time: 下午3:40
    * Create by :张福来
    * param :
    */
    public function selectBankcard($pagenum,$listNum,$w){
        $result["list"] = $this
                        ->where($w)
                        ->page($pagenum,$listNum)
                        ->order("defaultcard asc")
                        ->select();
        $result["total"] = $this
                        ->where($w)
                        ->count("id");
        return $result;
    }
    /*
    * Notes:
    * Create Date: 2018/10/31
    * Create Time: 下午5:26
    * Create by :张福来
    * param :
    */
    public function eidtBankcard($postData){
        $w["id"] = $postData["id"];
        unset($postData['id']);
        $result = $this
                ->where($w)
                ->update($postData);
        return $result;
    }
    /*
    * Notes:
    * Create Date: 2018/10/31
    * Create Time: 下午6:47
    * Create by :张福来
    * param :
    */
    public function deleteBankcard($w){
        $result = $this
                ->where($w)
                ->update(["status"=>9]);
        return $result;
    }
}